<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>提醒功能信息列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/systemStatic/style/admin.css">
    <link rel="stylesheet" href="${ctx}/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/css/public.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body>

<form class="layui-form  replyViewForm" lay-filter="replyViewForm" style="padding:20px 28px 16px 0;background: #fff" >
    <div class="layui-form-item">
        <label class="layui-form-label">标题:</label>
        <div class="layui-input-block">
            <input type="text"  readonly="readonly" name="subject" lay-verify="title" autocomplete="off"  class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">内容:</label>
        <div class="layui-input-block " style="padding:10px 0 0 0;">
            <div class="layui-textarea" style="height: 100px;overflow: auto;">
                <p id="showContent"></p>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">回复内容:</label>
        <div class="layui-input-block">
            <textarea    style="height: 100px" name="content" lay-verify="content" autocomplete="off"  class="layui-textarea"></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">私密回复：</label>
        <div  class="layui-input-block">
            <input  type="radio" name="isPrivate" value="1"  checked="" title="是">
            <input type="radio" name="isPrivate" value="0"  title="否" >
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block" style="text-align: center;margin: 0">
            <button  class="layui-btn add" type="submit" lay-submit lay-filter="reply">回复</button>
            <a  class="layui-btn cancelView layui-btn-danger">关闭</a>
        </div>
        <input type="hidden" name="id" value=/>
        <input type="hidden" name="replyId"  value="" />
        <input type="hidden" name="messageId" value="">
        <input type="hidden" name="messageContent" >
    </div>
</form>
<script src="${ctx}/public/component.js" type="text/javascript"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','table', 'layer', 'setter', 'commons','common', 'totalFilter', 'form','jquery','upload','layedit'], function () {
        var table = layui.table, layer = layui.layer, setter = layui.setter, commons = layui.commons, common = layui.common,
            totalFilter = layui.totalFilter, form = layui.form, $=layui.jquery;
        var layedit = layui.layedit;
        var messageId = '${messageId}';
        var id='${id}';
        $("input[name='messageId']").val(messageId);
        //初始化表单
        $.ajax({
            url: serverPath.systemPath + setter.sysLinkPath + "messageReply/edit",
            type: "get",
            contentType: 'application/json',
            dataType: 'json',
            data: {messageId: messageId,id:id},
            success: function (data) {
                if (commons._filterRecord(data)) {
                    var returnDate = data.data;
                    form.val('replyViewForm',{
                        "subject": returnDate.subject,
                        "messageContent": returnDate.content,
                        "messageId":returnDate.id,
                    });
                    var content=$("input[name='messageContent']").val();
                    $("#showContent").append(content)
                } else {
                    window.parent.layer.alert(data.msg);
                }
            }
        });
        //表单提交验证
        form.verify({
            content: function (value, item) { //value：表单的值、item：表单的DOM对象
                if (value == null || value == "") {
                    return '回复内容不能为空';
                }
            },
        });
        //监听提交事件
         form.on('submit(reply)', function (data) {
            $.ajax({
                url: serverPath.systemPath + setter.sysLinkPath + "messageReply/add",
                type: "POST",
                contentType: 'application/json',
                dataType: 'json',
                data: JSON.stringify(data.field),
                success: function (data) {
                    if (commons._filterRecord(data)) {
                        window.parent.layer.alert(data.msg, function (index) {
                            parent.layer.close(index);
                            parent.layer.close(parent.layer.getFrameIndex(window.name));
                            parent.layui.table.reload('messageReceiver');
                            parent.layui.totalFilter.init('messageReceiver');
                        });
                    } else {
                        layer.alert(data.msg);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    layer.alert("保存失败！" + XMLHttpRequest.status);
                }
            });
            return false;
        });
        $(".cancelView").click(function () {
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        })
    })
</script>
</body>
</html>